feat(Combinatorics/SimpleGraph/StarGraph): define star graphs#38027
feat(Combinatorics/SimpleGraph/StarGraph): define star graphs#380278e7 wants to merge 12 commits intoleanprover-community:masterfrom
Conversation
Welcome new contributor!Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests. We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR. Thank you again for joining our community. |
PR summary 2ff88851d5Import changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Please mark the review comments 'resolved' once you've addressed them so the next reviewer doesn't think they're still open. |
Co-authored-by: Vlad Tsyrklevich <vlad902@gmail.com>
IvanRenison
left a comment
There was a problem hiding this comment.
I like the idea!
Maybe we should have StarGraph in a separate graph
| · refine isAcyclic_iff_forall_adj_isBridge.mpr fun _ _ hadj ↦ ?_ | ||
| exact isBridge_iff_adj_and_not_isEdgeConnected_two.mpr ⟨hadj, h hadj.ne⟩ | ||
|
|
||
| section Star |
There was a problem hiding this comment.
How about moving this to a new file that imports Acyclic.lean?
There was a problem hiding this comment.
I suggested the same. I think it is a good idea to have it in a new file
There was a problem hiding this comment.
I agree to putting it in a new file. I'm considering adding some lemmas to characterize the metric of a star graph, as well as defining isomorphism between star graphs. Should I add these lemmas, or should I leave them for a future PR?
There was a problem hiding this comment.
I would add them in a separate pull request, to keep each pull request small, but both ways of doing it are okay
Co-authored-by: Snir Broshi <26556598+SnirBroshi@users.noreply.github.com>
Co-authored-by: Iván Renison <85908989+IvanRenison@users.noreply.github.com>
| lemma isTree_starGraph (r : V) : (starGraph r).IsTree := by | ||
| refine ⟨connected_starGraph r, isAcyclic_starGraph r⟩ |
There was a problem hiding this comment.
| lemma isTree_starGraph (r : V) : (starGraph r).IsTree := by | |
| refine ⟨connected_starGraph r, isAcyclic_starGraph r⟩ | |
| lemma isTree_starGraph (r : V) : (starGraph r).IsTree := | |
| ⟨connected_starGraph r, isAcyclic_starGraph r⟩ |
| rw [degree, neighborFinset_eq_filter (starGraph r)] | ||
| simp only [starGraph_adj, ne_eq, true_or, and_true] | ||
| have : ({w | ¬r = w} : Finset V) = Finset.univ.erase r := by | ||
| ext v; simp [eq_comm] | ||
| rw [this, Finset.card_erase_of_mem (Finset.mem_univ r), Finset.card_univ] |
There was a problem hiding this comment.
| rw [degree, neighborFinset_eq_filter (starGraph r)] | |
| simp only [starGraph_adj, ne_eq, true_or, and_true] | |
| have : ({w | ¬r = w} : Finset V) = Finset.univ.erase r := by | |
| ext v; simp [eq_comm] | |
| rw [this, Finset.card_erase_of_mem (Finset.mem_univ r), Finset.card_univ] | |
| simp [degree, neighborFinset_eq_filter (starGraph r), starGraph_adj, Finset.univ.filter_ne r] |
| · have hw : w = r := hadj.2.resolve_left h | ||
| replace hadj : w ≠ v ∧ (w = r ∨ v = r) := ⟨hadj.1.symm, hadj.2.symm⟩ | ||
| rw [reachable_comm, Sym2.eq_swap] | ||
| exact this r w v hadj hw |
There was a problem hiding this comment.
| · have hw : w = r := hadj.2.resolve_left h | |
| replace hadj : w ≠ v ∧ (w = r ∨ v = r) := ⟨hadj.1.symm, hadj.2.symm⟩ | |
| rw [reachable_comm, Sym2.eq_swap] | |
| exact this r w v hadj hw | |
| · rw [reachable_comm, Sym2.eq_swap] | |
| exact this r w v ⟨hadj.1.symm, hadj.2.symm⟩ (hadj.2.resolve_left h) |
| exact this r w v hadj hw | ||
| · subst h | ||
| apply not_reachable_of_neighborSet_right_eq_empty hadj.1 | ||
| ext x; aesop |
There was a problem hiding this comment.
| ext x; aesop | |
| ext x | |
| aesop |
Add a new definition
starGraphand several key lemmas. Star graphs are a trivial class of tree, often used in constructive proofs regarding trees.All lemmas are hand written first, then golfed with the help of Claude Code.